﻿namespace WXWorkSvc.Areas.Admin.Pages.Agent;

public class IndexModel : PageModel
{
    private readonly WXDbContext _context;

    public IndexModel(WXDbContext context)
    {
        _context = context;
    }

    public IList<TAgent> TAgent { get; set; } = default!;
    /// <summary>
    /// 
    /// </summary>
    /// <param name="id">CorpId</param>
    /// <returns></returns>
    public async Task OnGetAsync(string? id)
    {
        

        var q = from x in _context.Agents.Include(ii => ii.Suite).Include(ii => ii.Corp) select x;
        if (!string.IsNullOrEmpty(id))
            q = q.Where(ii => ii.CorpId == id);
        TAgent = await q.ToListAsync();
    }
}
